package com.eco.fanliapp.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eco.fanliapp.utils.DateUtils;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 提现记录表 app_withdrawal
 * 
 * @author xiaoxx
 * @date 2019-05-14
 */
@Getter
@Setter
@Data
@TableName("app_withdrawal")//@TableName中的值对应着表名
public class AppWithdrawal implements Serializable
{
	private static final long serialVersionUID = 1L;
	
	/** 主键id，自增 */
	@TableId(type = IdType.AUTO)
	@Excel(name = "关联Id",orderNum = "5")
	@NotNull(message = "关联Id不能为空")
	private Long id;
	/** 设备名称 */
	private String deviceName;
	/** 用户id */
	/*@NotNull(message = "用户编号不能为空")
	@Excel(name = "用户编号",orderNum = "1")*/
	private Long userId;
	/** 微信昵称 */
	//@Excel(name = "微信昵称",orderNum = "1")
	private String wechatNickname;
	/** 微信id */
	private String wechatId;
	/** 申请积分 */
	private Integer applicantScore;
	/**  处理状态：1，未处理；2，已处理；3，已拒绝 */
	@NotNull(message = "状态不能为空")
	@Excel(name = "状态",replace = { "未处理_1", "已处理_2","已拒绝_3"},isColumnHidden = true)
	private Integer applicantStatus;
	/** 处理结果（成功或者失败） */
	private String processingResults;
	/** 转账状态：1，不自动转账；2，自动转账 */
	private Integer transferState;
	/** 提现金额 */
	@NotNull(message = "转账金额不能为空")
	@Excel(name = "转账金额",orderNum = "3")
	private Double amount;
	/** 转账备注 */
	@Excel(name = "转账备注",orderNum = "4")
	private String remark;
	/** 拒绝原因 */
	@Excel(name = "错误信息",isColumnHidden = true)
	//@TableField(exist=false)
	private String refuseReason;
	/** 申请时间 */
	private Long applicantTime;
	/** 处理时间 */
	private Long processingTime;

	@TableField(exist=false)
	private String userUrl;

	/**
	 * 提现类型 1 支付宝 2 微信
	 */
	private Integer withdrawalType;

	/**
	 * 微信提现订单号
	 */
	private String partnerTradeNo;

	/**
	 * 用户真实姓名
	 */
	//@NotNull(message = "真实姓名不能为空")
	@Excel(name = "真实姓名",orderNum = "1")
	@TableField("alipay_real_name")
	private String userRealName;

	/**
	 * 支付宝账号
	 */
	//@NotNull(message = "支付宝账号不能为空")
	@Excel(name = "支付宝账号",orderNum = "2")
	@TableField("alipay_account")
	private String alipayAccount;


	/**
	 * 用户手机号
	 */
	/*@Excel(name = "手机号",orderNum = "2")*/
	@TableField("alipay_phone_number")
	private String phoneNumber;


	/**
	 * 状态（导入时使用）
	 */
	/*@NotNull(message = "状态不能为空")
	@Excel(name = "状态",orderNum = "2",isColumnHidden = true)
	@TableField(exist=false)
	private Integer status;*/

	//@NotNull(message = "时间不能为空")
	@Excel(name = "时间", importFormat = "yyyy-MM-dd HH:mm:ss",isColumnHidden = true)
	@TableField(exist=false)
	private String processingTimeDate;

	/**
	 * 用户余额是否为负数  1 是 0 否
	 */
	@TableField(exist=false)
	private Integer abnormalAmount = 0;

	public void setProcessingTimeDate(String processingTimeDate) {
		if(processingTimeDate != null){
			processingTime = DateUtils.datestr2LongByFormt(processingTimeDate,DateUtils.DATE_FORMAT_YYYYMMDDHHMMSS);
		}else{
			processingTime = new Date().getTime();
		}
		this.processingTimeDate = processingTimeDate;
	}
	public Integer getApplicantStatus() {
		return applicantStatus;
	}

	public void setApplicantStatus(Integer applicantStatus) {
		if(applicantStatus != null && applicantStatus == 4  )applicantStatus = 3;
		this.applicantStatus = applicantStatus;
	}

}
